package cn.com.thinvent.dispatch.web.controller;

import cn.com.thinvent.dispatch.entity.DataCleanResult;
import cn.com.thinvent.dispatch.entity.response.PagedGridResult;
import cn.com.thinvent.dispatch.entity.response.ReturnModel;
import cn.com.thinvent.dispatch.service.biz.DataCleanResultService;
import io.swagger.annotations.Api;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * 清洗任务结果模块管理
 */
@Api(description = "清洗任务结果模块")
@Controller
@RequestMapping("/dataCleanResult")
@CrossOrigin(origins = "*")
@ResponseBody
public class DataCleanResultController {

    @Autowired
    private DataCleanResultService dataCleanResultService;

    /**
     * 分页查询任务列表
     * @param taskId
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/list")
    @ResponseBody
    public ReturnModel list(@RequestParam("taskId") Integer taskId,
                            @RequestParam("pageNum") Integer pageNum,
                            @RequestParam("pageSize") Integer pageSize) {
        PagedGridResult<DataCleanResult> list = dataCleanResultService.list(taskId, pageNum, pageSize);
        return new ReturnModel(200, list, "");
    }

    /**
     * 新增或修改
     * @param dataCleanResult
     * @return
     */
    @PostMapping("/saveOrUpdate")
    @ResponseBody
    public ReturnModel saveOrUpdate(@RequestBody DataCleanResult dataCleanResult) {
//        System.out.println(taskDTO);
//        taskDTO.setUserId(UserContext.get());
        DataCleanResult result = dataCleanResultService.saveOrUpdate(dataCleanResult);

        return new ReturnModel(200, result, "");
    }
    /**
     * 详情
     * @param id 主键id
     * @return
     */
    @GetMapping("/detail")
    @ResponseBody
    public ReturnModel detail(@Param("id") Integer id) {

        DataCleanResult result = dataCleanResultService.getById(id);

        return new ReturnModel(200, result, "");
    }
}
